/*
* @Author: yanyanru
* @Date: 2018/4/11
* @description: 关联关系
*/
<template>
  <div class="custom-box p-20">
      <div class="custom-title">
          <h3>关联关系</h3>
      </div>
      <el-table  style="width:100%" class="m-t-10" :data='tableData' stripe>
          <el-table-column  label="ID" align="center" prop='id'>
          </el-table-column>
          <el-table-column  label="信息名称" align="center" prop='informationName'>
          </el-table-column>
          <el-table-column  label="关联类型" align="center" prop='relationType'>
            <template slot-scope="scope">
                {{scope.row.relationType | getNameById("eventType")}}
            </template>
          </el-table-column>
          <el-table-column  label="事件身份" align="center" prop='eventType'>
          </el-table-column>
          <el-table-column  label="轮次" align="center" prop='investRound'>
            <template slot-scope="scope">
                {{scope.row.investRound | getNameById("roundList")}}
            </template>
          </el-table-column>
          <el-table-column  label="创建时间" align="center">
             <template slot-scope="scope">
              <el-row>
                  <span>{{scope.row.createTime | cmsMoment}}</span>
                   <span class="m-l-5">{{scope.row.createName }}</span>
              </el-row>
            </template>
          </el-table-column>
          <el-table-column  label="操作" align="center">
              <template slot-scope="scope">
                <el-button  type="text" @click="edit(scope.row.id, scope.row.relationType)">编辑</el-button>
            </template>
          </el-table-column>
      </el-table>
      <el-pagination
        layout="prev, pager, next"
        :total="totalCount">
      </el-pagination>
  </div>
</template>
<script lang="ts">
import Vue from 'vue';
import { Component, Watch } from 'vue-property-decorator';
import PersonService from '../../../../service/subject/person';
import { PersonRelativeDto } from '../../../../service/subject/person/personInterface';
@Component({
    components: { }
})
export default class CompanyList extends Vue {
    // 初始化数据 相当于data
    public personSearch: PersonRelativeDto = {} as PersonRelativeDto; // <PersonRelativeDto>
    public value: string = ' ';
    public quality: object[] = this.$store.state.csConst.checkType;
    public totalPage: number = 100; // 总页数
    public totalCount: number = 100; // 总条数
    public tableData: object[] = [];
    // refs
    public $refs: { };
    // watch
    @Watch('value')
    public onChildChanged(val: string, oldVal: string) {
      return val + '***';
    }
    // 声明周期钩子
    public mounted() {
        this.getPersonRelation();
    }
    public created() {
      // this.getPersonRelation();
    }
    // 方法
    // 获取人物关联信息
    public async getPersonRelation() {
        this.personSearch.personId =  Number(this.$route.params.id);
        this.personSearch.pageIndex = 1;
        this.personSearch.pageSize = 10;
        const res = await PersonService.getPersonRelationByPersonId(this.personSearch);
        this.tableData = res.data.resultData.length > 0 ? res.data.resultData : [];
        this.totalCount = res.data.totalCount;
    }
    // 编辑关联关系
    public edit(id: string, type: number) {
        if (type === 17) {
            // 跳转该关联类型的 信息详情页
            this.$router.push({name: 'transaction-detail', params: {eventId: id, tabIndex: '0'}});
        } else {
            this.$router.push({name: 'new-issue-detail', params: {eventId: id, tabIndex: '0'}});
        }
        
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang='scss'>
.custom-title {
  height: 36px;
  overflow: hidden;
  h3 {
    font-weight: normal;
    font-size: 18px;
    color: #333333;
    float: left;
  }
}
</style>
